package ooday04;

import java.util.Timer;
import java.util.TimerTask;

//匿名内部类练习----定时器
public class TimerDemo {
    public static void main(String[] args) {
        Timer timer=new Timer();
        int interval=1000;
        timer.schedule(new TimerTask() {
            public void run() {
                System.out.println("开始学习了");
            }
        }, interval, interval);












        /*
        Timer timer=new Timer();//定时器对象
        int intervag=10000;//定时间隔
        timer.schedule(new TimerTask() {
            public void run() {
                System.out.println("该学习了");
            }
        }, intervag,intervag);

         */
    }
}
